﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Alipay.AopSdk.Core;
using Alipay.AopSdk.Core.Domain;
using Alipay.AopSdk.Core.Request;
using Alipay.Config;
using Microsoft.AspNetCore.Mvc;

namespace Alipay.Core.Demo.Controllers
{
    /// <summary>
    /// 订单查询
    /// </summary>
    public class Queryv : Controller
    {
        public IActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public async Task<JsonResult> Query(string tradeno, string alipayTradeNo)
        {
            /*DefaultAopClient client = new DefaultAopClient(Config.Gatewayurl, Config.AppId, Config.PrivateKey, "json", "2.0",
                Config.SignType, Config.AlipayPublicKey, Config.CharSet, false);*/
            AlipayTradeQueryModel model = new AlipayTradeQueryModel
            {
                OutTradeNo = tradeno,
                TradeNo = alipayTradeNo
            };

            AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
            request.SetBizModel(model);

            var response = await Configs.client.ExecuteAsync(request);
            return Json(response.Body);
        }
    }
}
